package cn.tedu.oop2;

public class TestCar {
    public static void main(String[] args) {
        Car c=new Car();
        System.out.println(c.getBrand());
        c.start();
        c.stop();
        BMW b=new BMW();
        System.out.println(b.getColor());
        System.out.println(b.color);
        b.start();
        b.stop();
        Car d=new TSL();
        //System.out.println(d.Color());
        d.start();
        d.stop();
        //d.swim();多态对象把自己看成父类型
    }

}
class Car{
    private String brand;
    private String color;
    private int id;
    private double price;

    //定义功能
    public void start(){
        System.out.println("我的小车车启动啦~");
    }
    public void stop(){
        System.out.println("我的小车车停止啦~");
    }

    //定义set和get
    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }
}

 class BMW extends Car{
    String color="五彩斑斓的黑";
    @Override
    public void start(){
         System.out.println("都让开,我的车要起飞咯~");
     }
 }
 class TSL extends Car{
    @Override
    public void stop(){
        System.out.println("哎呀妈呀,怎么停不下来呢");
    }
    public void swim(){
        System.out.println("没想到吧,我还是个潜水艇呢~");
    }
 }

